package data;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Polygon;
import java.text.AttributedCharacterIterator;

/**
 * @author sad
 */
public class InstrumentGraphics {

    private Graphics grahics;

    public InstrumentGraphics(Graphics grahics) {
        this.grahics = grahics;
    }

    public Color getColor() {
        return grahics.getColor();
    }

    public void setColor(Color c) {
        grahics.setColor(c);
    }

    public Font getFont() {
        return grahics.getFont();
    }

    public void setFont(Font font) {
        grahics.setFont(font);
    }

    public void drawPolygon(FPolygon polygon) {
        int count = polygon.npoints;
        int[] xs = new int[count];
        int[] ys = new int[count];
        for (int i = 0; i < count; i++) {
            xs[i] = (int) polygon.xpoints[i];
            ys[i] = (int) polygon.ypoints[i];
        }

        Polygon p = new Polygon(xs, ys, count);
        drawPolygon(p);
    }
    
    public void fillPolygon(FPolygon polygon) {
        int count = polygon.npoints;
        int[] xs = new int[count];
        int[] ys = new int[count];
        for (int i = 0; i < count; i++) {
            xs[i] = (int) polygon.xpoints[i];
            ys[i] = (int) polygon.ypoints[i];
        }

        Polygon p = new Polygon(xs, ys, count);
        fillPolygon(p);
    }
    
    public void drawLine(int x1, int y1, int x2, int y2) {
        grahics.drawLine(x1, y1, x2, y2);
    }
    
    public void drawLine(double x1, double y1, double x2, double y2) {
        grahics.drawLine((int)x1, (int)y1, (int)x2, (int)y2);
    }
    
    public void drawLine(FPoint p1, FPoint p2) {
        grahics.drawLine((int)p1.x, (int)p1.y, (int)p2.x, (int)p2.y);
    }

    public void fillRect(int x, int y, int width, int height) {
        grahics.fillRect(x, y, width, height);
    }
    
    public void fillRect(double x, double y, double width, double height) {
        grahics.fillRect((int)x, (int)y, (int)width, (int)height);
    }

    public void drawRect(int x, int y, int width, int height) {
        grahics.drawRect(x, y, width, height);
    }
    
    public void drawRect(double x, double y, double width, double height) {
        grahics.drawRect((int)x, (int)y, (int)width, (int)height);
    }

    public void drawOval(int x, int y, int width, int height) {
        grahics.drawOval(x, y, width, height);
    }

    public void fillOval(int x, int y, int width, int height) {
        grahics.fillOval(x, y, width, height);
    }
    
    public void drawOval(double x, double y, double width, double height) {
        grahics.drawOval((int)x, (int)y, (int)width, (int)height);
    }
    
    public void drawCircle(double x, double y, double radius) {
        grahics.drawOval((int)(x-radius), (int)(y-radius), (int)(radius*2), (int)(radius*2));
    }

    public void fillOval(double x, double y, double width, double height) {
        grahics.fillOval((int)x, (int)y, (int)width, (int)height);
    }
    
    public void fillCircle(double x, double y, double radius) {
        grahics.fillOval((int)(x-radius), (int)(y-radius), (int)(radius*2), (int)(radius*2));
    }

    public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) {
        grahics.drawPolygon(xPoints, yPoints, nPoints);
    }

    public void drawPolygon(Polygon p) {
        grahics.drawPolygon(p);
    }

    public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
        grahics.fillPolygon(xPoints, yPoints, nPoints);
    }

    public void fillPolygon(Polygon p) {
        grahics.fillPolygon(p);
    }

    public void drawString(String str, int x, int y) {
        grahics.drawString(str, x, y);
    }

    public void drawString(AttributedCharacterIterator iterator, int x, int y) {
        grahics.drawString(iterator, x, y);
    }
}
